import request from '../utils/request';
import { API_PATHS } from '../constants/api';

// 合同列表查询参数
export interface ContractListParams {
  current?: number;
  size?: number;
  contractName?: string;
  status?: string;
  [key: string]: any;
}

// 合同信息接口
export interface ContractInfo {
  id: string;
  contractName: string;
  contractNo: string;
  contractType: string;
  status: string;
  signTime: string;
  effectiveTime: string;
  expiryTime: string;
  partyA: string;
  partyB: string;
  amount: number;
  createdAt: string;
  updatedAt: string;
}

// 合同详情接口
export interface ContractDetail extends ContractInfo {
  contractContent: string;
  attachments: Array<{
    name: string;
    url: string;
  }>;
}

// 分页响应接口
export interface PaginationResponse<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

// 获取合同列表
export async function getContractList(params: ContractListParams): Promise<PaginationResponse<ContractInfo>> {
  const response = await request.post(API_PATHS.CONTRACT.LIST, params);
  return response.data;
}

// 获取合同详情
export async function getContractDetail(contractId: string): Promise<ContractDetail> {
  const response = await request.get(API_PATHS.CONTRACT.DETAIL(contractId));
  return response.data;
} 